/*
 * @Author: viivLgr 
 * @Date: 2018-03-23 16:36:36 
 * @Last Modified by: viivLgr
 * @Last Modified time: 2018-04-28 10:45:44
 */

'use strict';
var _util = require('util/util.js');
var _address = {
    // 更新地址
    update: function(addressInfo, resolve, reject){
        _util.request({
            url: _util.getServerUrl('/shipping/update.do'),
            data: addressInfo,
            success: resolve,
            error: reject
        });
    },
    // 获取某一条地址详细信息
    getAddress: function(shippingId, resolve, reject){
        _util.request({
            url: _util.getServerUrl('/shipping/select.do'),
            data: {
                shippingId: shippingId
            },
            success: resolve,
            error: reject
        });
    },
    // 删除
    del: function(shippingId, resolve, reject){
        _util.request({
            url: _util.getServerUrl('/shipping/del.do'),
            data: {
                shippingId: shippingId
            },
            success: resolve,
            error: reject
        });
    },
    // 保存收货地址
    save: function(addressInfo, resolve, reject){
        _util.request({
            url: _util.getServerUrl('/shipping/add.do'),
            data: addressInfo,
            method: "POST",
            success: resolve,
            error: reject
        });
    },
    // 获取地址列表
    getAddressList: function(resolve, reject){
        _util.request({
            url: _util.getServerUrl('/shipping/list.do'),
            data: {
                pageSize: 50
            },
            success: resolve,
            error: reject
        });
    }
};

module.exports = _address;